﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserOrderList.aspx.cs"
    Inherits="Maticsoft.Web.wap.UserOrderList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <!--#include file="include/head.htm"-->
    <style>
        .mui-control-content .mui-loading
        {
            margin-top: 50px;
        }
    </style>
    <script type="text/javascript">
        $(function () {
            LoadList();
        })

        function LoadList() {
            $.ajax({
                type: "get",
                url: "UserOrderList.aspx",
                data: "sync=true&act=" + $("#hidActive").val() + "&page=" + $("#hidPage").val() + "&d=" + new Date().toString(),
                success: function (msg) {
                    if (msg != "") {
                        var obj = eval('(' + msg + ')');
                        if (obj.code == "1") {
                            var res = "";
                            for (var i = 0; i < obj.data.length; i++) {
                                res += "<div class=\"mar-btm-10 bg-white \">";

                                res += "<div class=\"mui-row pad-10 bg-lred\">";
                                res += "<h5 class=\"tc-lgray mui-pull-left\">订单号：<span class=\"tc-black\">" + obj.data[i].OrderNo + "</span></h5>";
                                res += "<h5 class=\"tc-red mui-pull-right\">";
                                if (obj.data[i].Status == 1) {
                                    res += "待支付";
                                }
                                else if (obj.data[i].Status > 1 && obj.data[i].Status < 5) {
                                    res += "待收货";
                                }
                                else if (obj.data[i].Status == 5) {
                                    res += "待评价";
                                }
                                else if (obj.data[i].Status == 6) {
                                    res += "已评价";
                                }
                                else if (obj.data[i].Status == 7) {
                                    res += "已完成";
                                }
                                else if (obj.data[i].Status == 9) {
                                    res += "退货中";
                                }
                                else if (obj.data[i].Status == 10) {
                                    res += "已退货";
                                }
                                res += "</h5>";
                                res += "</div>";

                                res += "<div class=\"shop-list\">";
                                for (var j = 0; j < obj.data[i].oitem.length; j++) {
                                    res += "<div class=\"mui-media\">"
                                    res += "<img src=\"/uploadpic/" + obj.data[i].oitem[j].Pic + "\" class=\"mui-media-object\">"
                                    res += "<div class=\"mui-media-body\">"
                                    res += "<div class=\"mui-col-xs-7 mui-pull-left\">"
                                    res += "<h5 class=\"mui-ellipsis-2 tc-black\" style=\"margin-top: 0;\">" + obj.data[i].oitem[j].ProductName + "</h5>";
                                    res += "<h6 class=\"mui-ellipsis tc-lgray\">规格：" + obj.data[i].oitem[j].Desc + "</h6>";
                                    res += "</div>";
                                    res += "<div class=\"mui-col-xs-1 mui-pull-left mui-text-center\">";
                                    res += "<h5 class=\"tc-black\" style=\"margin-top: 0;\">￥" + obj.data[i].oitem[j].ProductPrice + "</h5>";
                                    res += "<h6 class=\"tc-lgray\">" + obj.data[i].oitem[j].ProductNum + "</h6>";
                                    res += "</div></div></div>";
                                }
                                res += "</div>";

                                res += "<div class=\"mui-row pad-10\">";
                                res += "<h5 class=\"mui-text-right\">共" + obj.data[i].ProductNum + "件商品，实付款：<span class=\"tc-black\">￥" + obj.data[i].Total + "</span></h5>";
                                res += "<div class=\"mui-row\">";
                                res += "<button class=\"mui-pull-right btn-red\" type=\"button\" onclick=\"Confirm(" + obj.data[i].OrderId + "," + obj.data[i].Status + ")\">"
                                if (obj.data[i].Status == 1) {
                                    res += "去支付";
                                }
                                else if (obj.data[i].Status > 1 && obj.data[i].Status < 5) {
                                    res += "确认收货";
                                }
                                else if (obj.data[i].Status == 5) {
                                    res += "去评价";
                                }
                                else if (obj.data[i].Status == 6) {
                                    res += "已评价";
                                }
                                else if (obj.data[i].Status == 7) {
                                    res += "已完成";
                                }
                                else if (obj.data[i].Status == 9) {
                                    res += "退货中";
                                }
                                else if (obj.data[i].Status == 10) {
                                    res += "已退货";
                                }
                                res += "</button>";
                                res += "<button class=\"mui-pull-right mar-rig-6\" type=\"button\" onclick=\"window.location.href='UserOrderDetail.aspx?id=" + obj.data[i].OrderId + "'\">订单详情</button>";
                                res += "</div>";
                                res += "</div>";

                                res += "</div>";
                            }
                        }

                        $("#list").append(res);

                        //alert(res);

                        if (parseInt(obj.total) > parseInt(obj.currPage)) {
                            $("#hidPage").val(parseInt(obj.currPage) + 1);
                            $("#listMore").show();
                        }
                        else {
                            $("#listMore").hide();
                        }
                    }
                },
                error: function (msg) {

                }
            })
        }

        function LoadMore() {
            LoadList();
        }

        function Confirm(id, state) {
            if (state == 1) {
                window.location.href = "/wap/pay/alipay/default.aspx?src=orderlist&orderid=" + id;
            }
            else if (state > 1 && state < 5) {
                $.ajax({
                    type: "get",
                    data: "orderid=" + id + "&d=" + new Date().toString(),
                    url: "ashx/order.ashx",
                    success: function (msg) {
                        if (msg == "1") {
                            window.reload();
                        }
                    },
                    error: function () {
                        alert("出错了");
                    }
                })
            }
            else if (state == 5) {
                window.location.href = "/wap/productcomments.aspx?id=" + id;
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:HiddenField ID="hidPage" runat="server" />
    <asp:HiddenField ID="hidActive" runat="server" />
    <header class="mui-bar">
			<a class="mui-action-back gotoup mui-pull-left"></a>
			<h1 class="mui-title">我的订单</h1>
	</header>
    <div class="mui-content">
        <div class="mui-slider">
            <div class="mui-slider-indicator mui-segmented-control mui-segmented-control-inverted bg-white">
                <a class="mui-control-item <%=(Request.QueryString["act"]=="all" || string.IsNullOrEmpty(Request.QueryString["act"])) ? "mui-active" : "" %>"
                    href="javascript:;" onclick="window.location.href='UserOrderList.aspx?act=all'">全部订单</a> <a class="mui-control-item <%=Request.QueryString["act"]=="pay" ? "mui-active" : "" %>"
                        href="javascript:;" onclick="window.location.href='UserOrderList.aspx?act=pay'">已付款订单 </a><a class="mui-control-item <%=Request.QueryString["act"]=="sent" ? "mui-active" : "" %>"
                            href="javascript:;" onclick="window.location.href='UserOrderList.aspx?act=sent'">已发货订单</a>
            </div>
            <!--<div class="mui-slider-progress-bar mui-col-xs-4 mar-btm-10">
            </div>-->
            <div class="mui-slider-group">
                <div class="mui-slider-item">
                    <div>
                        <!--列表开始-->
                        <div id="list">
                        </div>
                        <div id="listMore" style="width: 100%; text-align: center; line-height: 50px; background-color: #f6f4f4;
                            cursor: pointer;" onclick="LoadMore();">
                            加载更多</div>
                        <!--列表结束-->
                    </div>
                </div>
            </div>
        </div>
    </div>
    </form>
</body>
</html>
